package com.liuzy.beauty;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.liuzy.util.Util;

/**
 * http://www.zngirls.com/
 * 
 * @author liuzy
 * @since 2015年10月26日
 */
public class Zngirls extends Beauty {
	public static void main(String[] args) {
		new Zngirls("D:\\zngirls\\", "http://www.zngirls.com/").start();
	}

	public Zngirls(String saveDir, String startUrl) {
		super(saveDir, startUrl);
	}

	@Override
	public void search(String url, String html) {
		Matcher matcher = Pattern.compile("href=(\"|')?(/g/.*?/)").matcher(html);
		while (matcher.find()) {
			String path = "http://www.zngirls.com" + matcher.group(2);
			if (!Util.isHtml(path)) {
				grilQueue.add(path);
			}
		}
		matcher = Pattern.compile("href=(\"|')?(/girl/.*?/)").matcher(html);
		while (matcher.find()) {
			String path = "http://www.zngirls.com" + matcher.group(2);
			if (!Util.isHtml(path)) {
				grilQueue.add(path);
			}
		}
		matcher = Pattern.compile("http://t1.*?.jpg").matcher(html);
		while (matcher.find()) {
			String path = matcher.group();
			if (!Util.isHtml(path)) {
				imageQueue.add(path);
			}
		}
	}

	@Override
	public String reName(String url) {
		return url.substring(url.indexOf("gallery/") + 8).replaceAll("/", ".");
	}

}
